
//
//  SkinTools.swift
//  SkinPeeler
//
//  Created by xmg on 16/8/29.
//  Copyright © 2016年 wlis. All rights reserved.
//

import UIKit

private let kSkinName = "kSkinName"
class SkinTools: NSObject {

    static var skinName : String = {
     var skinName = NSUserDefaults.standardUserDefaults().objectForKey(kSkinName) as? String
        if skinName == nil {
        skinName = "chunjie"
        }
        return skinName!
    }()
}

extension SkinTools{

    /** 传入图标名称返回对应的图片的方法 */
    class func imageWithIconName(iconName : String) ->UIImage? {
        let iconPath = "skin/\(skinName)/\(iconName)"
        return UIImage(named: iconPath)
    }
}

extension SkinTools{

    /** 设置当前皮肤主题,记录用户选中皮肤 */
    class func setCurrentSkinName(skinName:String) {
        self.skinName = skinName
        NSUserDefaults.standardUserDefaults().setObject(skinName, forKey: kSkinName)
        NSUserDefaults.standardUserDefaults().synchronize()
    }
}

extension SkinTools{
    /** 返回背景颜色 */
    class  func TextBackgroundColor()->UIColor {
        switch skinName{
            case "chunjie":
            return UIColor.redColor()
            case "zhongqiu":
            return UIColor.orangeColor()
            case "guoqing":
            return UIColor.purpleColor()
        default:
            return UIColor.whiteColor()
        }
    }
}
